package com.mlk.car.controller;

import com.mlk.car.po.EngCar;
import com.mlk.car.po.EngCarEvilLog;
import com.mlk.car.service.EngCarService;
import com.mlk.car.vo.EngCarVO;
import com.mlk.core.component.page.Pager;
import com.mlk.core.util.ServerResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/car/manage")
public class CarController {

    @Resource
    private EngCarService engCarService;

    /**
     * 返回首页
     * @return
     */
    @RequestMapping("index")
    public String index(){
        return  "car/car";
    }

    /**
     * 分页查询数据
     * @param vo
     * @return
     */
    @RequestMapping("listPage")
    @ResponseBody
    public Pager listPage(EngCarVO vo){
        return this.engCarService.listPage(vo);
    }

    /**
     * 新增车辆信息
     * @return
     */
    @RequestMapping("add")
    @ResponseBody
    public ServerResponse add(EngCar car){
        return this.engCarService.add(car);
    }

    /**
     * 车辆分配
     * @return
     */
    @ResponseBody
    @RequestMapping("allocate")
    public ServerResponse allocate(EngCar car){
        return this.engCarService.allocate(car);
    }

    /**
     * 更新车辆信息
     * @return
     */
    @RequestMapping("update")
    @ResponseBody
    public ServerResponse update(EngCar car){
        return this.engCarService.update(car);
    }


    /**
     * 添加车辆违规记录
     * @return
     */
    @RequestMapping("addLog")
    @ResponseBody
    public ServerResponse addLog(EngCarEvilLog log){
        return this.engCarService.addLog(log);
    }

    /**
     * 查询车辆的违规记录内容
     * @param carId
     * @return
     */
    @ResponseBody
    @RequestMapping("listPageLog")
    public Pager listPageLog(Integer carId){
        return this.engCarService.listPageLog(carId);
    }
}
